package com.sgb.kjwl.view.ui.adapter.manage.helper;

import android.widget.ImageView;
import androidx.databinding.BindingAdapter;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.R;

public class ImageHelper {

    @BindingAdapter({"imageUrl"})
    public static void loadImage(ImageView imageView, String url) {
        RequestOptions options = new RequestOptions().placeholder(R.mipmap.morentu1_0_3)//图片加载出来前，显示的图片
                .fallback( R.mipmap.morentu1_0_3) //url为空的时候,显示的图片
                .error(R.mipmap.morentu1_0_3);//图片加载失败后，显示的图片
        Glide.with(imageView.getContext()).load(url).apply(options)//异常时候显示的图片
                .into(imageView);
    }

    @BindingAdapter({"imageCommonUrl"})
    public static void loadCommonImage(ImageView imageView, String url) {
        Glide.with(imageView.getContext()).load(url).into(imageView);
    }
}
